package net.tycmc.cty.ctyms.timejob.iems.dao;

import java.util.ArrayList;
import java.util.List;

import net.tycmc.bulb.common.dao.ITransactionDAO;

/**
 * 邮件日报
 * @author lixiaofan
 *
 */
public class UpdateEBPStateConn {
	ITransactionDAO tranDAO;
	
	public ITransactionDAO getTranDAO() {
		return tranDAO;
	}

	public void setTranDAO(ITransactionDAO tranDAO) {
		this.tranDAO = tranDAO;
	}

	public boolean UpdateEBPState(){
		List<String> sqlList = new ArrayList<String>();
		//更新载重量和EBP开关设定表
		sqlList.add("update Vcl_LoadInfo "
				+"set VclLI_EBPState=case (select count(MsgTkL_EBPEnableState) " 
				+"from CTY_Egn_B.dbo.Msg_Track_Last "  
				+"where VclLI_VclId=MsgTkL_Vcl_ID and MsgTkL_EBPEnableState is not null) when 0 then VclLI_EBPState " 
				+"else (select MsgTkL_EBPEnableState	from CTY_Egn_B.dbo.Msg_Track_Last "  
				+"where VclLI_VclId=MsgTkL_Vcl_ID and MsgTkL_EBPEnableState is not null) end");
		
		//更新载重量和EBP开关设定日志表
		sqlList.add("insert into Vcl_LoadInfoLog " 
				+"select 'localhost','iemsJob',2,GETDATE(),Vcl_LoadInfo.* from Vcl_LoadInfo " 
				+"inner join CTY_Egn_B.dbo.Msg_Track_Last on VclLI_VclId=MsgTkL_Vcl_ID  "
				+"where MsgTkL_EBPEnableState is not null");
		
		return tranDAO.batch(sqlList);
	}
}
